{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "基于上节得到的模型，我们可进一步编写Python代码，对X_test对应的输出数据进行预测"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Using TensorFlow backend.\n"
     ]
    }
   ],
   "source": [
    "import pickle\n",
    "\n",
    "with open('data/model.pkl', 'rb') as f:\n",
    "    model = pickle.load(f)\n",
    "\n",
    "with open('data/X_test.pkl', 'rb') as f:\n",
    "    X_test = pickle.load(f)\n",
    "\n",
    "with open('data/vstd.pkl', 'rb') as f:\n",
    "    vstd = pickle.load(f)\n",
    "    \n",
    "with open('data/vmean.pkl', 'rb') as f:\n",
    "    vmean = pickle.load(f)\n",
    "    \n",
    "preddf=model.predict(X_test)*vstd.values+vmean.values"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[1073.66409182, 1055.86633959, 1063.69458049, 1066.6233078 ],\n",
       "       [1075.5729809 , 1057.74085487, 1065.2558059 , 1068.69487333],\n",
       "       [1086.18729018, 1068.56050762, 1076.05891483, 1079.43816291],\n",
       "       [1085.19446016, 1067.1375268 , 1074.74765416, 1078.32758805],\n",
       "       [1117.13453484, 1099.43268684, 1106.91246576, 1110.91569206],\n",
       "       [1140.5293041 , 1121.69777066, 1128.86745354, 1132.94680444],\n",
       "       [1119.30009397, 1100.30960959, 1106.48506692, 1110.60372261],\n",
       "       [1130.73515589, 1112.98512923, 1119.13550159, 1125.47961647],\n",
       "       [1119.4101236 , 1100.89693763, 1106.51503934, 1111.47283142],\n",
       "       [1128.40882468, 1110.41081883, 1116.65375977, 1122.12443408],\n",
       "       [1157.76734411, 1138.92195855, 1145.9768362 , 1152.31210829],\n",
       "       [1153.59397441, 1133.75090842, 1140.50291328, 1146.14998061],\n",
       "       [1156.13931321, 1136.41166787, 1143.12569412, 1149.27220934],\n",
       "       [1143.46940868, 1124.52553249, 1130.39066199, 1136.46014838],\n",
       "       [1158.74854018, 1142.72930538, 1147.288032  , 1154.34059201],\n",
       "       [1156.33472424, 1140.3788397 , 1144.35553621, 1150.87591816],\n",
       "       [1152.54514365, 1140.94373841, 1141.83194979, 1149.28825943],\n",
       "       [1139.8010973 , 1129.11976432, 1129.29459288, 1136.28301263],\n",
       "       [1087.54149587, 1079.40079535, 1077.79154093, 1084.62045569],\n",
       "       [1111.59644287, 1101.46612996, 1101.53306623, 1106.43291004],\n",
       "       [1109.18624201, 1102.15406957, 1100.0824533 , 1105.78083475],\n",
       "       [1108.86772137, 1103.0884114 , 1100.50680299, 1106.93916998],\n",
       "       [1156.92069443, 1151.53153596, 1148.96402191, 1156.5438722 ],\n",
       "       [1154.38705531, 1148.54843499, 1144.89049839, 1152.28215247],\n",
       "       [1167.4376597 , 1164.44775437, 1159.02897906, 1167.87061808],\n",
       "       [1157.32571387, 1156.11231019, 1148.45215536, 1156.4772676 ],\n",
       "       [1190.09738639, 1187.61097266, 1181.53157971, 1190.98104988],\n",
       "       [1184.54890931, 1182.11732468, 1174.76897274, 1184.35230012],\n",
       "       [1178.79693658, 1175.61692017, 1168.72803921, 1178.3522328 ],\n",
       "       [1183.2179058 , 1180.71203099, 1173.50857435, 1183.0714774 ]])"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "preddf"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(30, 4)"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "preddf.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "with open('data/preddf.pkl', 'wb') as f:\n",
    "    pickle.dump(preddf, f)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
